//
//  LJEssionTableCell.m
//  百思不得姐
//
//  Created by 刘鹿杰 on 16/8/19.
//  Copyright © 2016年 刘鹿杰. All rights reserved.
//

#import "LJEssionTableCell.h"
#import "LJTopicsModel.h"
#import <UIImageView+WebCache.h>
#import "LJPictureView.h"


@interface LJEssionTableCell ()
@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
@property (weak, nonatomic) IBOutlet UILabel *titleName;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UIButton *guanzhuBtn;
@property (weak, nonatomic) IBOutlet UILabel *topicTextLabel;

/** pictureView*/
@property (nonatomic, weak) LJPictureView *pictureView;

@end


@implementation LJEssionTableCell

// 懒加载pictureView
-(LJPictureView *)pictureView{
    if (!_pictureView) {
        LJPictureView * pictureView  =  [LJPictureView pictureView];
        [self.contentView addSubview:pictureView];
        _pictureView = pictureView;
    }
    return _pictureView;
}

-(void)setTopicsModel:(LJTopicsModel *)topicsModel{
    _topicsModel = topicsModel;
    // 赋值数据
    self.titleName.text =  topicsModel.name;
    self.timeLabel.text = topicsModel.create_time;
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:topicsModel.profile_image] placeholderImage:[UIImage imageNamed:@"defaultUserIcon"]];
    self.topicTextLabel.text = topicsModel.text;
    
    if (topicsModel.type == LJTopicTypePicture) {
        self.pictureView.topicModel = topicsModel;
        self.pictureView.frame = topicsModel.pictureFrame;
    }
    
}

-(void)setFrame:(CGRect)frame{
    
    frame.origin.x = LJTopicPictureMargin;
    frame.size.width -= 2 * LJTopicPictureMargin;
    frame.size.height -= LJTopicPictureMargin;
    frame.origin.y += LJTopicPictureMargin;
    
    [super setFrame:frame];
}

@end
